define(function(require, exports, module) {
  require('css!./style.css');
  var _ = require('underscore');
  var tmpl = require('text!./tmpl.html');

  /**
   * [description]
   * @param { index, subIndex, type, name }
   * 1: MSP
   * 2: CMSP
   * @return DOM
   */
  return function(index, subIndex, type, name) {
    var id = 'CEG' + index + ['MSP', 'CMSP'][type-1] + subIndex;
    var title = '个人职业发展和家庭收入增长第'+ n2c(index) +'个三年规划';
    var subTitle = ['前端技术提升计划项目', '跨学科兴趣项目'][type-1];

    return _.template(tmpl)({
      id: id,
      name: name,
      title: title,
      subTitle: subTitle
    })
  }

  function n2c(n) {
    n = String(n);
    if (n.length > 4) {
      return n;
    }
    var str = "";
    for (var i = 0; i < n.length; i++) {
      str += '零一二三四五六七八九'.charAt(n.charAt(i)) + "千百十".substring(4-n.length).charAt(i);
    }
    return str.replace(/零(千|百|十)/g, "零").replace(/(零)+/g, "零").replace(/零$/, '').replace(/^一十/g, '十');
  }
})